//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_createmhqenemyteletrig.sqf"
#include "x_setup.sqf"

private ["_mhq", "_trig", "_trigger"];
_mhq = _this;

_trig = GV(_mhq,GVAR(enemy_trigger));
if (!isNil "_trig") then {
	if (!isNull _trig) then {
		deleteVehicle _trig;
	};
	_mhq setVariable [QGVAR(enemy_trigger), nil];
};

_trigger = [
position _mhq,
[GVAR(NoMHQTeleEnemyNear), GVAR(NoMHQTeleEnemyNear), 0, false],
[GVAR(enemy_side_trigger), "PRESENT", true],
["this",
format ["%1 setVariable ['d_enemy_near', true, true]", str(_mhq)],
format ["%1 setVariable ['d_enemy_near', false, true]", str(_mhq)]
]
] call FUNC(CreateTrigger);

_mhq setVariable [QGVAR(enemy_trigger), _trigger];

_trigger attachTo [_mhq, [0,0,0]];